package com.xsmart.order.dao;

import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author 周志成
 */
@Component
public interface YyDetailUrlDao {
    /**
     * 查询广告推荐转入地址
     * @param page
     * @param yyDetailUrlMap
     * @return
     */
    @Select("<script>select * from yy_detail_url where 1=1 <if test=\"remark!=null \">and remark like concat('%',#{remark},'%')</if><if test=\"status!=null\">and status=#{status}</if></script>")
    List<Map<String,Object>> queryYyDetailUrl(Pagination page, Map yyDetailUrlMap);

    /**
     * 新增广告推荐装入地址
     * @param yyDetailUrlMap
     * @return
     */
    @Insert("insert into yy_detail_url "+
            "(detail_url, "+
            "status, " +
            "remark)"+
            "values (" +
            "#{yyDetailUrlMap.detail_url}," +
            "#{yyDetailUrlMap.status}," +
            "#{yyDetailUrlMap.remark})")
    int addYyDetailUrl(@Param("yyDetailUrlMap")Map yyDetailUrlMap );

    /**
     * 修改广告推荐转入地址
     * @param yyDetailUrlMap
     * @return
     */
    @Update("update yy_detail_url " +
            "set " +
            "detail_url = #{yyDetailUrlMap.detail_url}, " +
            "status = #{yyDetailUrlMap.status}, " +
            "remark = #{yyDetailUrlMap.remark}"+
            "where du_id = #{yyDetailUrlMap.du_id}")
    int modYyDetailUrl(@Param("yyDetailUrlMap")Map yyDetailUrlMap );

    /**
     * 删除广告推荐转入地址
     * @param duId
     * @return
     */
    @Delete("DELETE FROM yy_detail_url WHERE du_id = #{duId}")
    int delYyDetailUrl(Integer duId);

    /**
     * 查询全部List
     * @return
     */
    @Select("select du_id as value," +
            "remark as label from yy_detail_url")
    List<Map<String, Object>> queryAllYyDetailUrl();
}
